use salvo::{handler, Depot, Request};

use crate::config::api_config::ApiResult;
use crate::service::login_service::LoginService;
use crate::vo::sys_menu_vo::MenuVo;
/// 登录
#[handler]
#[tracing::instrument]
pub async fn login(request: &mut Request, depot: &mut Depot) -> ApiResult<String> {
    let login_result = LoginService::login(request, depot).await;
    ApiResult::from(login_result)
}

/// 登出
#[handler]
#[tracing::instrument]
pub async fn logout(request: &mut Request, depot: &mut Depot) -> ApiResult<()> {
    let logout_result = LoginService::logout(request, depot).await;
    ApiResult::from(logout_result)
    
}

/// 用户菜单
#[handler]
#[tracing::instrument]
pub async fn user_tree_menu(depot: &mut Depot) -> ApiResult<Option<Vec<MenuVo>>> {
    let menu = LoginService::get_login_menu(depot).await;
    ApiResult::from(menu)
}
